package com.SouthernWall_404.age_tool.common.world.Entity;

import com.SouthernWall_404.age_tool.common.init.ModBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

public class ExcuteBlockEntity extends TriggerBlockEntity{


    public boolean isTriggered = false;

    public ExcuteBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
        super(blockEntityType, blockPos, blockState);
    }

    public ExcuteBlockEntity(BlockPos pos, BlockState blockState) {
        super(ModBlockEntities.EXCUTER_BLOCK_ENTITY.get(),pos, blockState);
    }

    public void tick() {
//        if (this.level != null && !this.level.isClientSide) {
//            TriggersCap triggersCap = getTriggers();
//            if (triggersCap != null) {
//                boolean shouldBeCharged = triggersCap.isActive(this.remoteId);
//
//                // 如果状态改变，更新并通知周围方块
//                if (shouldBeCharged != this.isCharged) {
//                    this.isCharged = shouldBeCharged;
//                    this.setChanged();
//
//                    // 通知周围方块更新
//
//                    this.level.updateNeighborsAt(this.worldPosition, this.getBlockState().getBlock());
//                }
//            }
//        }
    }

    @Override
    public void load(CompoundTag nbt) {
        super.load(nbt);
        // 从NBT加载充能状态
        if (nbt.contains("charged")) {
            this.isTriggered = nbt.getBoolean("charged");
        }
    }

    @Override
    protected void saveAdditional(CompoundTag nbt) {
        super.saveAdditional(nbt);
        // 保存充能状态到NBT
        nbt.putBoolean("charged", this.isTriggered);
    }


}
